home *** CD-ROM | disk | FTP | other *** search
/ Ultra Pack / UltraComputing Partner Applications.iso / SunLabs / tclTK / src / tk4.0 / tests / textWind.test < prev    next >
Encoding:
Text File  |  1995-05-19  |  28.0 KB  |  820 lines

  1. # This file is a Tcl script to test the code in the file tkTextWind.c.
  2. # This file is organized in the standard fashion for Tcl tests.
  3. #
  4. # Copyright (c) 1994 The Regents of the University of California.
  5. # Copyright (c) 1994-1995 Sun Microsystems, Inc.
  6. #
  7. # See the file "license.terms" for information on usage and redistribution
  8. # of this file, and for a DISCLAIMER OF ALL WARRANTIES.
  9. #
  10. # @(#) textWind.test 1.15 95/04/30 16:25:34
  11.  
  12. if {[string compare test [info procs test]] == 1} then \
  13.   {source defs}
  14.  
  15. foreach i [winfo child  .] {
  16.     catch {destroy $i}
  17. }
  18. if [catch {text .t \
  19.     -font -adobe-courier-medium-r-normal--12-120-75-75-m-70-iso8859-1 \
  20.     -width 30 -height 6}] {
  21.     puts "The font needed by these tests isn't available, so I'm"
  22.     puts "going to skip the tests."
  23.     return
  24. }
  25. pack append . .t {top expand fill}
  26. update
  27. .t debug on
  28. wm geometry . {}
  29. if {[winfo depth .t] > 1} {
  30.     set color green
  31. } else {
  32.     set color black
  33. }
  34.   
  35. # The statements below reset the main window;  it's needed if the window
  36. # manager is mwm to make mwm forget about a previous minimum size setting.
  37.  
  38. wm withdraw .
  39. wm minsize . 1 1
  40. wm positionfrom . user
  41. wm deiconify .
  42.  
  43. test textWind-1.1 {basic tests of options} {
  44.     .t delete 1.0 end
  45.     .t insert end "This is the first line"
  46.     .t insert end "\nAnd this is a second line, which wraps around"
  47.     frame .f -width 3 -height 3 -bg $color
  48.     .t window create 2.2 -window .f
  49.     update
  50.     list [winfo ismapped .f] [winfo geom .f] [.t bbox .f] \
  51.         [.t window configure .f -window]
  52. } {1 3x3+19+23 {19 23 3 3} {-window {} {} {} .f}}
  53. test textWind-1.2 {basic tests of options} {
  54.     .t delete 1.0 end
  55.     .t insert end "This is the first line"
  56.     .t insert end "\nAnd this is a second line, which wraps around"
  57.     frame .f -width 3 -height 3 -bg $color
  58.     .t window create 2.2 -window .f -align top
  59.     update
  60.     list [winfo ismapped .f] [winfo geom .f] [.t bbox .f] \
  61.         [.t window configure .f -align]
  62. } {1 3x3+19+18 {19 18 3 3} {-align {} {} center top}}
  63. test textWind-1.3 {basic tests of options} {
  64.     .t delete 1.0 end
  65.     .t insert end "This is the first line"
  66.     .t insert end "\nAnd this is a second line, which wraps around"
  67.     .t window create 2.2 -create "Test script"
  68.     .t window configure 2.2 -create
  69. } {-create {} {} {} {Test script}}
  70. test textWind-1.4 {basic tests of options} {
  71.     .t delete 1.0 end
  72.     .t insert end "This is the first line"
  73.     .t insert end "\nAnd this is a second line, which wraps around"
  74.     frame .f -width 10 -height 20 -bg $color
  75.     .t window create 2.2 -window .f -padx 5
  76.     update
  77.     list [winfo geom .f] [.t window configure .f -padx] [.t bbox 2.3]
  78. } {10x20+24+18 {-padx {} {} 0 5} {39 21 7 13}}
  79. test textWind-1.5 {basic tests of options} {
  80.     .t delete 1.0 end
  81.     .t insert end "This is the first line"
  82.     .t insert end "\nAnd this is a second line, which wraps around"
  83.     frame .f -width 10 -height 20 -bg $color
  84.     .t window create 2.2 -window .f -pady 4
  85.     update
  86.     list [winfo geom .f] [.t window configure .f -pady] [.t bbox 2.31]
  87. } {10x20+19+22 {-pady {} {} 0 4} {19 46 7 13}}
  88. test textWind-1.6 {basic tests of options} {
  89.     .t delete 1.0 end
  90.     .t insert end "This is the first line"
  91.     .t insert end "\nAnd this is a second line, which wraps around"
  92.     frame .f -width 5 -height 5 -bg $color
  93.     .t window create 2.2 -window .f -stretch 1
  94.     update
  95.     list [winfo geom .f] [.t window configure .f -stretch]
  96. } {5x13+19+18 {-stretch {} {} 0 1}}
  97.  
  98. .t delete 1.0 end
  99. .t insert end "This is the first line"
  100. frame .f -width 10 -height 6 -bg $color
  101. .t window create 1.3 -window .f -padx 1 -pady 2
  102. test textWind-2.1 {TkTextWindowCmd procedure} {
  103.     list [catch {.t window} msg] $msg
  104. } {1 {wrong # args: should be ".t window option ?arg arg ...?"}}
  105. test textWind-2.2 {TkTextWindowCmd procedure, "cget" option} {
  106.     list [catch {.t window cget} msg] $msg
  107. } {1 {wrong # args: should be ".t window cget index option"}}
  108. test textWind-2.3 {TkTextWindowCmd procedure, "cget" option} {
  109.     list [catch {.t window cget a b c} msg] $msg
  110. } {1 {wrong # args: should be ".t window cget index option"}}
  111. test textWind-2.4 {TkTextWindowCmd procedure, "cget" option} {
  112.     list [catch {.t window cget gorp -padx} msg] $msg
  113. } {1 {bad text index "gorp"}}
  114. test textWind-2.5 {TkTextWindowCmd procedure, "cget" option} {
  115.     list [catch {.t window cget 1.2 -padx} msg] $msg
  116. } {1 {no embedded window at index "1.2"}}
  117. test textWind-2.6 {TkTextWindowCmd procedure, "cget" option} {
  118.     list [catch {.t window cget .f -bogus} msg] $msg
  119. } {1 {unknown option "-bogus"}}
  120. test textWind-2.7 {TkTextWindowCmd procedure, "cget" option} {
  121.     list [catch {.t window cget .f -pady} msg] $msg
  122. } {0 2}
  123. test textWind-2.8 {TkTextWindowCmd procedure} {
  124.     list [catch {.t window co} msg] $msg
  125. } {1 {wrong # args: should be ".t window configure index ?option value ...?"}}
  126. test textWind-2.9 {TkTextWindowCmd procedure} {
  127.     list [catch {.t window configure gorp} msg] $msg
  128. } {1 {bad text index "gorp"}}
  129. test textWind-2.10 {TkTextWindowCmd procedure} {
  130.     .t delete 1.0 end
  131.     list [catch {.t window configure 1.0} msg] $msg
  132. } {1 {no embedded window at index "1.0"}}
  133. test textWind-2.11 {TkTextWindowCmd procedure} {
  134.     .t delete 1.0 end
  135.     .t insert end "This is the first line"
  136.     .t insert end "\nAnd this is a second line, which wraps around"
  137.     frame .f -width 10 -height 6 -bg $color
  138.     .t window create 2.2 -window .f -align baseline -padx 1 -pady 2 -create foo
  139.     update
  140.     list [catch {.t window configure .f} msg] $msg
  141. } {0 {{-align {} {} center baseline} {-create {} {} {} foo} {-padx {} {} 0 1} {-pady {} {} 0 2} {-stretch {} {} 0 0} {-window {} {} {} .f}}}
  142. test textWind-2.12 {TkTextWindowCmd procedure} {
  143.     .t delete 1.0 end
  144.     .t insert end "This is the first line"
  145.     .t insert end "\nAnd this is a second line, which wraps around"
  146.     frame .f -width 10 -height 6 -bg $color
  147.     .t window create 2.2 -window .f -align baseline -padx 1 -pady 2 -create foo
  148.     update
  149.     list [.t window configure .f -padx 33] [.t window configure .f -padx]
  150. } {{} {-padx {} {} 0 33}}
  151. test textWind-2.13 {TkTextWindowCmd procedure} {
  152.     .t delete 1.0 end
  153.     .t insert end "This is the first line"
  154.     .t insert end "\nAnd this is a second line, which wraps around"
  155.     frame .f -width 10 -height 6 -bg $color
  156.     .t window create 2.2 -window .f -align baseline -padx 1 -pady 2
  157.     update
  158.     list [.t window configure .f -padx 14 -pady 15] \
  159.         [.t window configure .f -padx] [.t window configure .f -pady]
  160. } {{} {-padx {} {} 0 14} {-pady {} {} 0 15}}
  161. test textWind-2.14 {TkTextWindowCmd procedure} {
  162.     list [catch {.t window create} msg] $msg
  163. } {1 {wrong # args: should be ".t window create index ?option value ...?"}}
  164. test textWind-2.15 {TkTextWindowCmd procedure} {
  165.     list [catch {.t window create gorp} msg] $msg
  166. } {1 {bad text index "gorp"}}
  167. test textWind-2.16 {TkTextWindowCmd procedure, don't insert after end} {
  168.     .t delete 1.0 end
  169.     .t insert end "Line 1\nLine 2"
  170.     frame .f -width 20 -height 10 -bg $color
  171.     .t window create end -window .f
  172.     .t index .f
  173. } {2.6}
  174. test textWind-2.17 {TkTextWindowCmd procedure} {
  175.     .t delete 1.0 end
  176.     list [catch {.t window create 1.0} msg] $msg [.t window configure 1.0]
  177. } {0 {} {{-align {} {} center center} {-create {} {} {} {}} {-padx {} {} 0 0} {-pady {} {} 0 0} {-stretch {} {} 0 0} {-window {} {} {} {}}}}
  178. test textWind-2.18 {TkTextWindowCmd procedure} {
  179.     .t delete 1.0 end
  180.     frame .f -width 10 -height 6 -bg $color
  181.     list [catch {.t window create 1.0 -window .f -gorp stupid} msg] $msg \
  182.         [winfo exists .f] [.t index 1.end] [catch {.t index .f}]
  183. } {1 {unknown option "-gorp"} 0 1.0 1}
  184. test textWind-2.19 {TkTextWindowCmd procedure} {
  185.     .t delete 1.0 end
  186.     frame .f -width 10 -height 6 -bg $color
  187.     list [catch {.t window create 1.0 -gorp -window .f stupid} msg] $msg \
  188.         [winfo exists .f] [.t index 1.end] [catch {.t index .f}]
  189. } {1 {unknown option "-gorp"} 1 1.0 1}
  190. test textWind-2.20 {TkTextWindowCmd procedure} {
  191.     list [catch {.t window c} msg] $msg
  192. } {1 {bad window option "c":  must be cget, configure, create, or names}}
  193. destroy .f
  194. test textWind-2.21 {TkTextWindowCmd procedure, "names" option} {
  195.     list [catch {.t window names foo} msg] $msg
  196. } {1 {wrong # args: should be ".t window names"}}
  197. test textWind-2.22 {TkTextWindowCmd procedure, "names" option} {
  198.     .t delete 1.0 end
  199.     .t window names
  200. } {}
  201. test textWind-2.23 {TkTextWindowCmd procedure, "names" option} {
  202.     .t delete 1.0 end
  203.     foreach i {.f .f2 .t.f .t.f2} {
  204.     frame $i -width 20 -height 20
  205.     .t window create end -window $i
  206.     }
  207.     set result [.t window names]
  208.     destroy .f .f2 .t.f .t.f2
  209.     lsort $result
  210. } {.f .f2 .t.f .t.f2}
  211.  
  212. test textWind-3.1 {EmbWinConfigure procedure} {
  213.     .t delete 1.0 end
  214.     frame .f -width 10 -height 6 -bg $color
  215.     .t window create 1.0 -window .f
  216.     list [catch {.t window configure 1.0 -foo bar} msg] $msg
  217. } {1 {unknown option "-foo"}}
  218. test textWind-3.2 {EmbWinConfigure procedure} {
  219.     .t delete 1.0 end
  220.     .t insert 1.0 "Some sample text"
  221.     frame .f -width 10 -height 20 -bg $color
  222.     .t window create 1.3 -window .f
  223.     update
  224.     .t window configure 1.3 -window {}
  225.     update
  226.     list [catch {.t index .f} msg] $msg [winfo ismapped .f] [.t bbox 1.4]
  227. } {1 {bad text index ".f"} 0 {26 5 7 13}}
  228. catch {destroy .f}
  229. test textWind-3.3 {EmbWinConfigure procedure} {
  230.     .t delete 1.0 end
  231.     .t insert 1.0 "Some sample text"
  232.     frame .t.f -width 10 -height 20 -bg $color
  233.     .t window create 1.3 -window .t.f
  234.     update
  235.     .t window configure 1.3 -window {}
  236.     update
  237.     list [catch {.t index .t.f} msg] $msg [winfo ismapped .t.f] [.t bbox 1.4]
  238. } {1 {bad text index ".t.f"} 0 {26 5 7 13}}
  239. catch {destroy .t.f}
  240. test textWind-3.4 {EmbWinConfigure procedure} {
  241.     .t delete 1.0 end
  242.     .t insert 1.0 "Some sample text"
  243.     frame .f -width 10 -height 20 -bg $color
  244.     .t window create 1.3
  245.     update
  246.     .t window configure 1.3 -window .f
  247.     update
  248.     list [catch {.t index .f} msg] $msg [winfo ismapped .f] [.t bbox 1.4]
  249. } {0 1.3 1 {36 8 7 13}}
  250. test textWind-3.5 {EmbWinConfigure procedure} {
  251.     .t delete 1.0 end
  252.     .t insert 1.0 "Some sample text"
  253.     frame .f
  254.     frame .f.f -width 15 -height 20 -bg $color
  255.     pack .f.f
  256.     list [catch {.t window create 1.3 -window .f.f} msg] $msg
  257. } {1 {can't embed .f.f in .t}}
  258. catch {destroy .f}
  259. test textWind-3.6 {EmbWinConfigure procedure} {
  260.     .t delete 1.0 end
  261.     .t insert 1.0 "Some sample text"
  262.     toplevel .t2 -width 20 -height 10 -bg $color
  263.     .t window create 1.3
  264.     list [catch {.t window configure 1.3 -window .t2} msg] $msg \
  265.         [.t window configure 1.3 -window]
  266. } {1 {can't embed .t2 in .t} {-window {} {} {} {}}}
  267. catch {destroy .t2}
  268. test textWind-3.7 {EmbWinConfigure procedure} {
  269.     .t delete 1.0 end
  270.     .t insert 1.0 "Some sample text"
  271.     .t window create 1.3
  272.     list [catch {.t window configure 1.3 -window .t} msg] $msg
  273. } {1 {can't embed .t in .t}}
  274. test textWind-3.8 {EmbWinConfigure procedure} {
  275.     # This test checks for various errors when the text claims
  276.     # a window away from itself.
  277.     .t delete 1.0 end
  278.     .t insert 1.0 "Some sample text"
  279.     button .t.b -text "Hello!"
  280.     .t window create 1.4 -window .t.b
  281.     .t window create 1.6 -window .t.b
  282.     update
  283.     .t index .t.b
  284. } {1.6}
  285.  
  286. .t delete 1.0 end
  287. frame .f -width 10 -height 20 -bg $color
  288. .t window create 1.0 -window .f
  289. test textWind-4.1 {AlignParseProc and AlignPrintProc procedures} {
  290.     .t window configure 1.0 -align baseline
  291.     .t window configure 1.0 -align
  292. } {-align {} {} center baseline}
  293. test textWind-4.2 {AlignParseProc and AlignPrintProc procedures} {
  294.     .t window configure 1.0 -align bottom
  295.     .t window configure 1.0 -align
  296. } {-align {} {} center bottom}
  297. test textWind-4.3 {AlignParseProc and AlignPrintProc procedures} {
  298.     .t window configure 1.0 -align center
  299.     .t window configure 1.0 -align
  300. } {-align {} {} center center}
  301. test textWind-4.4 {AlignParseProc and AlignPrintProc procedures} {
  302.     .t window configure 1.0 -align top
  303.     .t window configure 1.0 -align
  304. } {-align {} {} center top}
  305. test textWind-4.5 {AlignParseProc and AlignPrintProc procedures} {
  306.     .t window configure 1.0 -align top
  307.     list [catch {.t window configure 1.0 -align gorp} msg] $msg \
  308.         [.t window configure 1.0 -align]
  309. } {1 {bad alignment "gorp": must be baseline, bottom, center, or top} {-align {} {} center top}}
  310.  
  311. test textWind-5.1 {EmbWinStructureProc procedure} {
  312.     .t delete 1.0 end
  313.     .t insert 1.0 "Some sample text"
  314.     frame .f -width 10 -height 20 -bg $color
  315.     .t window create 1.2 -window .f
  316.     update
  317.     destroy .f
  318.     list [catch {.t index .f} msg] $msg [.t bbox 1.2] [.t bbox 1.3]
  319. } {1 {bad text index ".f"} {19 11 0 0} {19 5 7 13}}
  320. test textWind-5.2 {EmbWinStructureProc procedure} {
  321.     .t delete 1.0 end
  322.     .t insert 1.0 "Some sample text"
  323.     frame .f -width 10 -height 20 -bg $color
  324.     .t window create 1.2 -align bottom
  325.     .t window configure 1.2 -window .f
  326.     update
  327.     destroy .f
  328.     list [catch {.t index .f} msg] $msg [.t bbox 1.2] [.t bbox 1.3]
  329. } {1 {bad text index ".f"} {19 18 0 0} {19 5 7 13}}
  330. test textWind-5.3 {EmbWinStructureProc procedure} {
  331.     .t delete 1.0 end
  332.     .t insert 1.0 "Some sample text"
  333.     .t window create 1.2 -create {frame .f -width 10 -height 20 -bg $color}
  334.     update
  335.     .t window configure 1.2 -create {frame .f -width 20 -height 10 -bg $color}
  336.     destroy .f
  337.     update
  338.     list [catch {.t index .f} msg] $msg [.t bbox 1.2] [.t bbox 1.3]
  339. } {0 1.2 {19 6 20 10} {39 5 7 13}}
  340.  
  341. test textWind-6.1 {EmbWinRequestProc procedure} {
  342.     .t delete 1.0 end
  343.     .t insert 1.0 "Some sample text"
  344.     frame .f -width 10 -height 20 -bg $color
  345.     .t window create 1.2 -window .f
  346.     set result {}
  347.     lappend result [.t bbox 1.2] [.t bbox 1.3]
  348.     .f configure -width 25 -height 30
  349.     lappend result [.t bbox 1.2] [.t bbox 1.3]
  350. } {{19 5 10 20} {29 8 7 13} {19 5 25 30} {44 13 7 13}}
  351.  
  352. test textWind-7.1 {EmbWinLostSlaveProc procedure} {
  353.     .t delete 1.0 end
  354.     .t insert 1.0 "Some sample text"
  355.     frame .f -width 10 -height 20 -bg $color
  356.     .t window create 1.2 -window .f
  357.     update
  358.     place .f -in .t -x 100 -y 50
  359.     update
  360.     list [winfo geom .f] [.t bbox 1.2]
  361. } {10x20+104+54 {19 11 0 0}}
  362. test textWind-7.2 {EmbWinLostSlaveProc procedure} {
  363.     .t delete 1.0 end
  364.     .t insert 1.0 "Some sample text"
  365.     frame .t.f -width 10 -height 20 -bg $color
  366.     .t window create 1.2 -window .t.f
  367.     update
  368.     place .t.f -x 100 -y 50
  369.     update
  370.     list [winfo geom .t.f] [.t bbox 1.2]
  371. } {10x20+104+54 {19 11 0 0}}
  372. catch {destroy .f}
  373. catch {destroy .t.f}
  374.  
  375. test textWind-8.1 {EmbWinDeleteProc procedure} {
  376.     .t delete 1.0 end
  377.     .t insert 1.0 "Some sample text"
  378.     frame .f -width 10 -height 20 -bg $color
  379.     .t window create 1.2 -window .f
  380.     bind .f <Destroy> {set x destroyed}
  381.     set x XXX
  382.     .t delete 1.2
  383.     list $x [.t bbox 1.2] [.t bbox 1.3] [catch {.t index .f} msg] $msg \
  384.         [winfo exists .f]
  385. } {destroyed {19 5 7 13} {26 5 7 13} 1 {bad text index ".f"} 0}
  386.  
  387. test textWind-9.1 {EmbWinCleanupProc procedure} {
  388.     .t delete 1.0 end
  389.     .t insert 1.0 "Some sample text\nA second line."
  390.     frame .f -width 10 -height 20 -bg $color
  391.     .t window create 2.3 -window .f
  392.     .t delete 1.5 2.1
  393.     .t index .f
  394. } 1.7
  395.  
  396. proc tkerror args {
  397.     global msg
  398.     set msg $args
  399. }
  400.  
  401. test textWind-10.1 {EmbWinLayoutProc procedure} {
  402.     .t delete 1.0 end
  403.     .t insert 1.0 "Some sample text"
  404.     .t window create 1.5 -create {
  405.     frame .f -width 10 -height 20 -bg $color
  406.     }
  407.     update
  408.     list [winfo exists .f] [winfo geom .f] [.t index .f]
  409. } {1 10x20+40+5 1.5}
  410. test textWind-10.2 {EmbWinLayoutProc procedure, error in creating window} {
  411.     .t delete 1.0 end
  412.     .t insert 1.0 "Some sample text"
  413.     .t window create 1.5 -create {
  414.     error "couldn't create window"
  415.     }
  416.     set msg xyzzy
  417.     update
  418.     list $msg [.t bbox 1.5]
  419. } {{{couldn't create window}} {40 11 0 0}}
  420. test textWind-10.3 {EmbWinLayoutProc procedure, error in creating window} {
  421.     .t delete 1.0 end
  422.     .t insert 1.0 "Some sample text"
  423.     .t window create 1.5 -create {
  424.     concat gorp
  425.     }
  426.     set msg xyzzy
  427.     update
  428.     list $msg [.t bbox 1.5]
  429. } {{{bad window path name "gorp"}} {40 11 0 0}}
  430. test textWind-10.4 {EmbWinLayoutProc procedure, error in creating window} {
  431.     .t delete 1.0 end
  432.     .t insert 1.0 "Some sample text"
  433.     .t window create 1.5 -create {
  434.     frame .t.f
  435.     frame .t.f.f -width 10 -height 20 -bg $color
  436.     }
  437.     set msg xyzzy
  438.     update
  439.     list $msg [.t bbox 1.5] [winfo exists .t.f.f]
  440. } {{{can't embed .t.f.f relative to .t}} {40 11 0 0} 1}
  441. catch {destroy .t.f}
  442. test textWind-10.5 {EmbWinLayoutProc procedure, error in creating window} {
  443.     .t delete 1.0 end
  444.     .t insert 1.0 "Some sample text"
  445.     .t window create 1.5 -create {
  446.     concat .t
  447.     }
  448.     set msg xyzzy
  449.     update
  450.     list $msg [.t bbox 1.5]
  451. } {{{can't embed .t relative to .t}} {40 11 0 0}}
  452. test textWind-10.6 {EmbWinLayoutProc procedure, error in creating window} {
  453.     .t delete 1.0 end
  454.     .t insert 1.0 "Some sample text"
  455.     .t window create 1.5 -create {
  456.     toplevel .t2 -width 100 -height 150
  457.     wm geom .t2 +0+0
  458.     concat .t2
  459.     }
  460.     set msg xyzzy
  461.     update
  462.     list $msg [.t bbox 1.5]
  463. } {{{can't embed .t2 relative to .t}} {40 11 0 0}}
  464. test textWind-10.7 {EmbWinLayoutProc procedure, steal window from self} {
  465.     .t delete 1.0 end
  466.     .t insert 1.0 ABCDEFGHIJKLMNOP
  467.     button .t.b -text "Hello!"
  468.     .t window create 1.5 -window .t.b
  469.     update
  470.     .t window create 1.3 -create {concat .t.b}
  471.     update
  472.     .t index .t.b
  473. } {1.3}
  474. catch {destroy .t2}
  475. test textWind-10.8 {EmbWinLayoutProc procedure, doesn't fit on line} {
  476.     .t configure -wrap char
  477.     .t delete 1.0 end
  478.     .t insert 1.0 "Some sample text"
  479.     frame .f -width 125 -height 20 -bg $color -bd 2 -relief raised
  480.     .t window create 1.12 -window .f
  481.     list [.t bbox .f] [.t bbox 1.13]
  482. } {{89 5 126 20} {5 25 7 13}}
  483. test textWind-10.9 {EmbWinLayoutProc procedure, doesn't fit on line} {
  484.     .t configure -wrap char
  485.     .t delete 1.0 end
  486.     .t insert 1.0 "Some sample text"
  487.     frame .f -width 126 -height 20 -bg $color -bd 2 -relief raised
  488.     .t window create 1.12 -window .f
  489.     update
  490.     list [.t bbox .f] [.t bbox 1.13]
  491. } {{89 5 126 20} {5 25 7 13}}
  492. test textWind-10.10 {EmbWinLayoutProc procedure, doesn't fit on line} {
  493.     .t configure -wrap char
  494.     .t delete 1.0 end
  495.     .t insert 1.0 "Some sample text"
  496.     frame .f -width 127 -height 20 -bg $color -bd 2 -relief raised
  497.     .t window create 1.12 -window .f
  498.     update
  499.     list [.t bbox .f] [.t bbox 1.13]
  500. } {{5 18 127 20} {132 21 7 13}}
  501. test textWind-10.11 {EmbWinLayoutProc procedure, doesn't fit on line} {
  502.     .t configure -wrap none
  503.     .t delete 1.0 end
  504.     .t insert 1.0 "Some sample text"
  505.     frame .f -width 130 -height 20 -bg $color -bd 2 -relief raised
  506.     .t window create 1.12 -window .f
  507.     update
  508.     list [.t bbox .f] [.t bbox 1.13]
  509. } {{89 5 126 20} {}}
  510. test textWind-10.12 {EmbWinLayoutProc procedure, doesn't fit on line} {
  511.     .t configure -wrap none
  512.     .t delete 1.0 end
  513.     .t insert 1.0 "Some sample text"
  514.     frame .f -width 130 -height 220 -bg $color -bd 2 -relief raised
  515.     .t window create 1.12 -window .f
  516.     update
  517.     list [.t bbox .f] [.t bbox 1.13]
  518. } {{89 5 126 78} {}}
  519. test textWind-10.13 {EmbWinLayoutProc procedure, doesn't fit on line} {
  520.     .t configure -wrap char
  521.     .t delete 1.0 end
  522.     .t insert 1.0 "Some sample text"
  523.     frame .f -width 250 -height 220 -bg $color -bd 2 -relief raised
  524.     .t window create 1.12 -window .f
  525.     update
  526.     list [.t bbox .f] [.t bbox 1.13]
  527. } {{5 18 210 65} {}}
  528.  
  529. test textWind-11.1 {EmbWinDisplayProc procedure, geometry transforms} {
  530.     .t delete 1.0 end
  531.     .t insert 1.0 "Some sample text"
  532.     pack forget .t
  533.     place .t -x 30 -y 50
  534.     frame .f -width 30 -height 20 -bg $color
  535.     .t window create 1.12 -window .f
  536.     update
  537.     winfo geom .f
  538. } {30x20+119+55}
  539. place forget .t
  540. pack .t
  541. test textWind-11.2 {EmbWinDisplayProc procedure, geometry transforms} {
  542.     .t delete 1.0 end
  543.     .t insert 1.0 "Some sample text"
  544.     pack forget .t
  545.     place .t -x 30 -y 50
  546.     frame .t.f -width 30 -height 20 -bg $color
  547.     .t window create 1.12 -window .t.f
  548.     update
  549.     winfo geom .t.f
  550. } {30x20+89+5}
  551. place forget .t
  552. pack .t
  553. test textWind-11.3 {EmbWinDisplayProc procedure, configuration optimization} {
  554.     .t delete 1.0 end
  555.     .t insert 1.0 "Some sample text"
  556.     frame .f -width 30 -height 20 -bg $color
  557.     .t window create 1.12 -window .f
  558.     update
  559.     bind .f <Configure> {set x ".f configured"}
  560.     set x {no configures}
  561.     .t delete 1.0
  562.     .t insert 1.0 "X"
  563.     update
  564.     set x
  565. } {no configures}
  566. test textWind-11.4 {EmbWinDisplayProc procedure, horizontal scrolling} {
  567.     .t delete 1.0 end
  568.     .t insert 1.0 "xyzzy\nFirst window here: "
  569.     .t configure -wrap none
  570.     frame .f -width 30 -height 20 -bg $color
  571.     .t window create end -window .f
  572.     .t insert end " and second here: "
  573.     frame .f2 -width 40 -height 10 -bg $color
  574.     .t window create end -window .f2
  575.     .t insert end " with junk after it."
  576.     .t xview moveto 0
  577.     .t xview scroll 5 units
  578.     update
  579.     list [winfo ismapped .f] [winfo geom .f] [.t bbox .f] [winfo ismapped .f2]
  580. } {1 30x20+103+18 {103 18 30 20} 0}
  581. test textWind-11.5 {EmbWinDisplayProc procedure, horizontal scrolling} {
  582.     .t delete 1.0 end
  583.     .t insert 1.0 "xyzzy\nFirst window here: "
  584.     .t configure -wrap none
  585.     frame .f -width 30 -height 20 -bg $color
  586.     .t window create end -window .f
  587.     .t insert end " and second here: "
  588.     frame .f2 -width 40 -height 10 -bg $color
  589.     .t window create end -window .f2
  590.     .t insert end " with junk after it."
  591.     update
  592.     .t xview moveto 0
  593.     .t xview scroll 25 units
  594.     update
  595.     list [winfo ismapped .f] [winfo ismapped .f2] [winfo geom .f2] [.t bbox .f2]
  596. } {0 1 40x10+119+23 {119 23 40 10}}
  597. .t configure -wrap char
  598.  
  599. test textWind-12.1 {EmbWinUndisplayProc procedure, mapping/unmapping} {
  600.     .t delete 1.0 end
  601.     .t insert 1.0 "Some sample text"
  602.     frame .f -width 30 -height 20 -bg $color
  603.     .t window create 1.2 -window .f
  604.     bind .f <Map> {lappend x mapped}
  605.     bind .f <Unmap> {lappend x unmapped}
  606.     set x created
  607.     update
  608.     lappend x modified
  609.     .t delete 1.0
  610.     update
  611.     lappend x replaced
  612.     .t window configure .f -window {}
  613.     .t delete 1.1
  614.     .t window create 1.4 -window .f
  615.     update
  616.     lappend x off-screen
  617.     .t configure -wrap none
  618.     .t insert 1.0 "Enough text to make the line run off-screen"
  619.     update
  620.     set x
  621. } {created mapped modified replaced unmapped mapped off-screen unmapped}
  622.  
  623. test textWind-13.1 {EmbWinBboxProc procedure} {
  624.     .t delete 1.0 end
  625.     .t insert 1.0 "Some sample text"
  626.     frame .f -width 5 -height 5 -bg $color
  627.     .t window create 1.2 -window .f -align top -padx 2 -pady 1
  628.     update
  629.     list [winfo geom .f] [.t bbox .f]
  630. } {5x5+21+6 {21 6 5 5}}
  631. test textWind-13.2 {EmbWinBboxProc procedure} {
  632.     .t delete 1.0 end
  633.     .t insert 1.0 "Some sample text"
  634.     frame .f -width 5 -height 5 -bg $color
  635.     .t window create 1.2 -window .f -align center -padx 2 -pady 1
  636.     update
  637.     list [winfo geom .f] [.t bbox .f]
  638. } {5x5+21+9 {21 9 5 5}}
  639. test textWind-13.3 {EmbWinBboxProc procedure} {
  640.     .t delete 1.0 end
  641.     .t insert 1.0 "Some sample text"
  642.     frame .f -width 5 -height 5 -bg $color
  643.     .t window create 1.2 -window .f -align baseline -padx 2 -pady 1
  644.     update
  645.     list [winfo geom .f] [.t bbox .f]
  646. } {5x5+21+10 {21 10 5 5}}
  647. test textWind-13.4 {EmbWinBboxProc procedure} {
  648.     .t delete 1.0 end
  649.     .t insert 1.0 "Some sample text"
  650.     frame .f -width 5 -height 5 -bg $color
  651.     .t window create 1.2 -window .f -align bottom -padx 2 -pady 1
  652.     update
  653.     list [winfo geom .f] [.t bbox .f]
  654. } {5x5+21+12 {21 12 5 5}}
  655. test textWind-13.5 {EmbWinBboxProc procedure} {
  656.     .t delete 1.0 end
  657.     .t insert 1.0 "Some sample text"
  658.     frame .f -width 5 -height 5 -bg $color
  659.     .t window create 1.2 -window .f -align top -padx 2 -pady 1 -stretch 1
  660.     update
  661.     list [winfo geom .f] [.t bbox .f]
  662. } {5x11+21+6 {21 6 5 11}}
  663. test textWind-13.6 {EmbWinBboxProc procedure} {
  664.     .t delete 1.0 end
  665.     .t insert 1.0 "Some sample text"
  666.     frame .f -width 5 -height 5 -bg $color
  667.     .t window create 1.2 -window .f -align center -padx 2 -pady 1 -stretch 1
  668.     update
  669.     list [winfo geom .f] [.t bbox .f]
  670. } {5x11+21+6 {21 6 5 11}}
  671. test textWind-13.7 {EmbWinBboxProc procedure} {
  672.     .t delete 1.0 end
  673.     .t insert 1.0 "Some sample text"
  674.     frame .f -width 5 -height 5 -bg $color
  675.     .t window create 1.2 -window .f -align baseline -padx 2 -pady 1 -stretch 1
  676.     update
  677.     list [winfo geom .f] [.t bbox .f]
  678. } {5x9+21+6 {21 6 5 9}}
  679. test textWind-13.8 {EmbWinBboxProc procedure} {
  680.     .t delete 1.0 end
  681.     .t insert 1.0 "Some sample text"
  682.     frame .f -width 5 -height 5 -bg $color
  683.     .t window create 1.2 -window .f -align bottom -padx 2 -pady 1 -stretch 1
  684.     update
  685.     list [winfo geom .f] [.t bbox .f]
  686. } {5x11+21+6 {21 6 5 11}}
  687. test textWind-13.9 {EmbWinBboxProc procedure, spacing options} {
  688.     .t configure -spacing1 5 -spacing3 2
  689.     .t delete 1.0 end
  690.     .t insert 1.0 "Some sample text"
  691.     frame .f -width 5 -height 5 -bg $color
  692.     .t window create 1.2 -window .f -align center -padx 2 -pady 1
  693.     update
  694.     list [winfo geom .f] [.t bbox .f]
  695. } {5x5+21+14 {21 14 5 5}}
  696. .t configure -spacing1 0 -spacing2 0 -spacing3 0
  697.  
  698. test textWind-14.1 {EmbWinDelayedUnmap procedure} {
  699.     .t delete 1.0 end
  700.     .t insert 1.0 "Some sample text"
  701.     frame .f -width 30 -height 20 -bg $color
  702.     .t window create 1.2 -window .f
  703.     update
  704.     bind .f <Unmap> {lappend x unmapped}
  705.     set x modified
  706.     .t insert 1.0 x
  707.     lappend x removed
  708.     .t window configure .f -window {}
  709.     lappend x updated
  710.     update
  711.     set x
  712. } {modified removed unmapped updated}
  713. catch {destroy .f}
  714. test textWind-14.2 {EmbWinDelayedUnmap procedure} {
  715.     .t delete 1.0 end
  716.     .t insert 1.0 "Some sample text"
  717.     frame .f -width 30 -height 20 -bg $color
  718.     .t window create 1.2 -window .f
  719.     update
  720.     bind .f <Unmap> {lappend x unmapped}
  721.     set x modified
  722.     .t insert 1.0 x
  723.     lappend x deleted
  724.     .t delete .f
  725.     lappend x updated
  726.     update
  727.     set x
  728. } {modified deleted updated}
  729. test textWind-14.3 {EmbWinDelayedUnmap procedure} {
  730.     .t delete 1.0 end
  731.     .t insert 1.0 "Some sample text\nAnother line\n3\n4\n5\n6\n7\n8\n9"
  732.     frame .f -width 30 -height 20 -bg $color
  733.     .t window create 1.2 -window .f
  734.     update
  735.     .t yview 2.0
  736.     set result [winfo ismapped .f]
  737.     update
  738.     list $result [winfo ismapped .f]
  739. } {1 0}
  740. test textWind-14.4 {EmbWinDelayedUnmap procedure} {
  741.     .t delete 1.0 end
  742.     .t insert 1.0 "Some sample text\nAnother line\n3\n4\n5\n6\n7\n8\n9"
  743.     frame .t.f -width 30 -height 20 -bg $color
  744.     .t window create 1.2 -window .t.f
  745.     update
  746.     .t yview 2.0
  747.     set result [winfo ismapped .t.f]
  748.     update
  749.     list $result [winfo ismapped .t.f]
  750. } {1 0}
  751. catch {destroy .t.f}
  752. catch {destroy .f}
  753.  
  754. test textWind-15.1 {TkTextWindowIndex procedure} {
  755.     list [catch {.t index .foo} msg] $msg
  756. } {1 {bad text index ".foo"}}
  757. test textWind-15.2 {TkTextWindowIndex procedure} {
  758.     .t configure -wrap none
  759.     .t delete 1.0 end
  760.     .t insert 1.0 "Some sample text"
  761.     frame .f -width 30 -height 20 -bg $color
  762.     .t window create 1.6 -window .f
  763.     .t tag add a 1.1
  764.     .t tag add a 1.3
  765.     list [.t index .f] [.t bbox 1.7]
  766. } {1.6 {77 8 7 13}}
  767.  
  768. test textWind-16.1 {EmbWinTextStructureProc procedure} {
  769.     .t configure -wrap none
  770.     .t delete 1.0 end
  771.     .t insert 1.0 "Some sample text"
  772.     frame .f -width 30 -height 20 -bg $color
  773.     .t window create 1.6 -window .f
  774.     update
  775.     pack forget .t
  776.     update
  777.     winfo ismapped .f
  778. } 0
  779. pack .t
  780. test textWind-16.2 {EmbWinTextStructureProc procedure} {
  781.     .t configure -wrap none
  782.     .t delete 1.0 end
  783.     .t insert 1.0 "Some sample text"
  784.     frame .f -width 30 -height 20 -bg $color
  785.     .t window create 1.6 -window .f
  786.     update
  787.     set result {}
  788.     lappend result [winfo geom .f] [.t bbox .f]
  789.     frame .f2 -width 150 -height 30 -bd 2 -relief raised
  790.     pack .f2 -before .t
  791.     update
  792.     lappend result [winfo geom .f] [.t bbox .f]
  793. } {30x20+47+5 {47 5 30 20} 30x20+47+35 {47 5 30 20}}
  794. catch {destroy .f2}
  795. test textWind-16.3 {EmbWinTextStructureProc procedure} {
  796.     .t configure -wrap none
  797.     .t delete 1.0 end
  798.     .t insert 1.0 "Some sample text"
  799.     .t window create 1.6
  800.     update
  801.     pack forget .t
  802.     update
  803. } {}
  804. pack .t
  805. test textWind-16.4 {EmbWinTextStructureProc procedure} {
  806.     .t configure -wrap none
  807.     .t delete 1.0 end
  808.     .t insert 1.0 "Some sample text"
  809.     frame .t.f -width 30 -height 20 -bg $color
  810.     .t window create 1.6 -window .t.f
  811.     update
  812.     pack forget .t
  813.     update
  814.     list [winfo ismapped .t.f] [.t bbox .t.f]
  815. } {1 {47 5 30 20}}
  816. pack .t
  817.  
  818. catch {destroy .t}
  819. concat {}
  820.